package gam.t1;

import gam.t1.appraisal2.AppraisalCommand;
import gam.t1.appraisal2.DIConfig;
import gam.t1.appraisal2.Data;
import gam.t1.appraisal2.InvClickEvent;
import gam.t1.appraisal2.dinv.AppraisalConfig;
import gam.t1.appraisal2.dinv.AppraisalMsg;
import gam.t1.appraisal2.dinv.AppraisalOption;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class PreNeigeitem extends JavaPlugin {
    @Override
    public void onEnable() {
        if(!Bukkit.getPluginManager().isPluginEnabled("NeigeItems")){
            getLogger().warning("You dont have the plugin enabled : NeigeItems");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }
        DIConfig.register(new AppraisalConfig(this,"itemConfig.yml"));
        DIConfig.register(new AppraisalOption(this,"config.yml"));
        DIConfig.register(new AppraisalMsg(this,"msg.yml"));
        DIConfig.loadAll();
        getServer().getPluginManager().registerEvents(new InvClickEvent(),this);
        getServer().getPluginCommand("appraisal").setExecutor(new AppraisalCommand());
//        ActionManager.INSTANCE.getItemActions().forEach((s,b) -> {
//            System.out.println("=====================");
//            System.out.println("ItemName: " + s);
//            System.out.println("ItemActionTriggers: ");
//            b.getTriggers().forEach((ss,bb) ->{
//                System.out.println("    ★★★★★★★★★★★★★★★★★★★");
//                System.out.println("    - TriggerType: " + ss);
//                System.out.println("    - Id: " + bb.getId());
//                System.out.println("    - Actions: " + bb.getActions());
//                System.out.println("    - Sync: " + bb.getSync());
//                System.out.println("    - Async: " + bb.getAsync());
//                System.out.println("    ★★★★★★★★★★★★★★★★★★★");
//                bb.run(new ActionContext(Bukkit.getPlayer("aikupla")));
//            });
//            System.out.println("=====================");
//        });
    }
    @Override
    public void onDisable() {
        Bukkit.getOnlinePlayers().forEach($p -> {
            if (Data.getInventory($p.getUniqueId()) != null && Data.getAppraisalDataInventory($p.getUniqueId()) != null ) $p.closeInventory();
        });
    }
}
